﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_UserTrainingApply : DLL.MyAdminPage
{
	private DLL.TrainingPerson.Component clsTrainingPersonComp;
	private DLL.User.Component clsUserComp;

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
			BindGridView();
		}
	}

	protected override void OnInit(EventArgs e)
	{
		clsTrainingPersonComp = new DLL.TrainingPerson.Component(Page);
		clsUserComp = new DLL.User.Component(Page);

		base.OnInit(e);

		Grv.RowCommand += new GridViewCommandEventHandler(Grv_RowCommand);
	}

	void Grv_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		if (e.CommandName == "MyApply")
		{
			if (clsTrainingPersonComp.TrainingApply(Convert.ToInt32(e.CommandArgument)))
			{
				TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "报名成功！");
				BindGridView();
			}
		}
	}

	private void BindGridView()
	{
		Grv.DataSource = clsTrainingPersonComp.QueryOneLearnerCanApplyTraining(clsUserComp.GetOne(nUserID).IDCard);
		Grv.DataKeyNames = new string[] { "ID" };
		Grv.DataBind();
	}
}